import {
  q as u,
  p as K,
  ap as Q,
  X as D,
  f as Z,
  H as ee,
  av as z,
  aw as te,
  k as t,
  l as a,
  m as l,
  az as ae,
  as as o,
  aG as le,
  at as m,
  ay as se
} from "./index-b50e6ef9.js";
import { f as E } from "./finance-81050a55.js";
function A(p) {
  return (
    typeof p == "function" ||
    (Object.prototype.toString.call(p) === "[object Object]" && !se(p))
  );
}
function ie(p) {
  const y = u([]),
    F = u([]),
    r = u(!0);
  u({}), K();
  const W = u(1),
    v = u(10),
    C = u(1),
    S = u(10),
    g = u({}),
    c = u([]),
    I = Q("reload"),
    x = D({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    w = D({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [5, 10, 20],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    J = D({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    L = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "用户ID", prop: "user_id", minWidth: 150 },
      { label: "用户名", prop: "user_name", minWidth: 150 },
      { label: "手机号", prop: "user_phone", minWidth: 150 },
      {
        label: "身份",
        prop: "user_place",
        minWidth: 150,
        formatter: ({ user_place: e }) =>
          t("span", null, [
            e == 1
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("一星合伙人")] }
                )
              : e == 2
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("二星合伙人")] }
                )
              : e == 3
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("三星合伙人")] }
                )
              : e == 4
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("四星合伙人")] }
                )
              : e == 5
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("五星合伙人")] }
                )
              : e == 6
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("一星联创")] }
                )
              : e == 7
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("二星联创")] }
                )
              : e == 8
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("三星联创")] }
                )
              : e == 9
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("四星联创")] }
                )
              : e == 10
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("一星董事")] }
                )
              : e == 11
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("二星董事")] }
                )
              : e == 12
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("三星董事")] }
                )
              : t(
                  a("el-tag"),
                  { class: "mx-1", type: "info", effect: "light" },
                  { default: () => [l("暂无")] }
                )
          ])
      },
      {
        label: "点位",
        prop: "user_divvy",
        minWidth: 120,
        formatter: ({ user_divvy: e }) =>
          e ||
          t(
            a("el-tag"),
            { class: "mx-1", type: "danger", effect: "light" },
            { default: () => [l("暂无")] }
          )
      },
      {
        label: "订单数",
        prop: "indent",
        minWidth: 120,
        formatter: ({ indent: e }) =>
          e ||
          t(
            a("el-tag"),
            { class: "mx-1", type: "danger", effect: "light" },
            { default: () => [l("暂无")] }
          )
      },
      { label: "推荐人数", prop: "vip", minWidth: 120 },
      {
        label: "奖励金额",
        prop: "income",
        minWidth: 120,
        formatter: ({ income: e, reach: s }) =>
          s == 1
            ? t(
                a("el-text"),
                { tag: "del", style: "color:#B5B5B5" },
                A(e) ? e : { default: () => [e] }
              )
            : t(a("el-text"), null, A(e) ? e : { default: () => [e] })
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 120,
        formatter: ({ status: e }) =>
          e == 1
            ? t(
                a("el-tag"),
                { class: "mx-1", type: "info", effect: "light" },
                { default: () => [l("未发放")] }
              )
            : t(
                a("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [l("已发放")] }
              )
      },
      {
        label: "时间",
        prop: "create_time",
        minWidth: 230,
        formatter: ({ create_time: e, update_time: s }) =>
          t("div", null, [
            t("div", null, [l("创建时间:"), e]),
            t("div", null, [l("修改时间:"), s])
          ])
      }
    ],
    N = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "首单", prop: "shou", minWidth: 120 },
      { label: "复购", prop: "fu", minWidth: 120 },
      { label: "百分比后总额", prop: "money", minWidth: 120 },
      { label: "总点数", prop: "count", minWidth: 120 },
      { label: "单个点数金额", prop: "divvy", minWidth: 120 },
      { label: "创建时间", prop: "create_time", minWidth: 180 }
    ],
    k = Z(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function U(e) {
    ae(e);
  }
  async function V(e) {
    const s = { role_id: e.role_id },
      d = JSON.stringify(s),
      h = { value: o.enc.Base64.stringify(o.enc.Utf8.parse(d)) },
      i = await le(h);
    i.code == 200
      ? (m("删除成功", { type: "success" }), I())
      : m(i.msg, { type: "error" });
  }
  function O() {}
  function T(e) {
    (v.value = e), B(void 0, e);
  }
  function j(e) {
    (S.value = e), b(void 0, e);
  }
  function M(e) {
    (W.value = e), B(e, void 0);
  }
  function R(e) {
    (C.value = e), b(e, void 0);
  }
  function H(e) {}
  function P(e) {}
  function _(e) {
    (J.text = `正在加载第${e}页...`),
      (r.value = !0),
      z(600).then(() => {
        r.value = !1;
      });
  }
  async function q(e, s = []) {
    (c.value = []),
      s == null ||
        s.map(X => {
          const Y = X,
            $ = new Date(Y);
          c.value.push(
            $.toLocaleDateString("zh-CN", {
              year: "numeric",
              month: "2-digit",
              day: "2-digit"
            })
          );
        }),
      (r.value = !0),
      (g.value = e);
    const d = {
        page: 1,
        pagesize: v.value,
        content: "dayDivvy",
        user_phone: e.user_phone,
        sort: e.sort,
        reach: e.reach,
        status: e.status,
        start: c.value[0],
        end: c.value[1]
      },
      f = JSON.stringify(d),
      i = { value: o.enc.Base64.stringify(o.enc.Utf8.parse(f)) },
      { data: n } = await E(i);
    (y.value = n.divvy.data),
      (x.total = n.divvy.total),
      setTimeout(() => {
        r.value = !1;
      }, 500);
  }
  async function B(e = W.value, s = v.value) {
    const d = {
        page: e,
        pagesize: s,
        content: "dayDivvy",
        sort: g.value.sort,
        user_phone: g.value.user_phone,
        status: g.value.status,
        reach: g.value.reach,
        start: c.value[0],
        end: c.value[1]
      },
      f = JSON.stringify(d),
      i = { value: o.enc.Base64.stringify(o.enc.Utf8.parse(f)) },
      n = await E(i);
    n.code === 200
      ? ((y.value = n.data.divvy.data),
        (x.total = n.data.divvy.total),
        setTimeout(() => {
          r.value = !1;
        }, 500))
      : m(n.msg, { type: "error" });
  }
  async function b(e = C.value, s = S.value) {
    const f = JSON.stringify({ page: e, pagesize: s, content: "dayDivvyLog" }),
      i = { value: o.enc.Base64.stringify(o.enc.Utf8.parse(f)) },
      n = await E(i);
    n.code === 200
      ? ((F.value = n.data.day.data),
        (w.total = n.data.day.total),
        setTimeout(() => {
          r.value = !1;
        }, 500))
      : m(n.msg, { type: "error" });
  }
  const G = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    ee(() => {
      z().then(() => {
        const { setWatermark: e } = te(p.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        B(),
        b();
    }),
    {
      loading: r,
      columns: L,
      columnsDatil: N,
      dataList: y,
      dataListDatil: F,
      pagination: x,
      paginationDatil: w,
      buttonClass: k,
      onSearch: q,
      resetForm: G,
      handleaddUser: O,
      handleUpdate: U,
      handleDelete: V,
      handleSizeChange: T,
      handleSizeChangeDatil: j,
      handleCurrentChange: M,
      handleCurrentChangeDatil: R,
      handleSelectionChange: H,
      handleSelectionChangeDatil: P,
      onCurrentChange: _
    }
  );
}
export { ie as useRole };
